Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Postgres FTS Migration #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shivam-tripathi
Copy link
Member

@shivam-tripathi shivam-tripathi commented May 3, 2018

Migration script for making necessary changes to support Postgres FTS.

@LordSputnik Open for review.

* Add extentions pg_trgm, unaccent, btree_gin repectively for trigram fuzzy
	search, unaccenting strings and using gin index.
* Add column tokens TSVECTOR to alias table to add tokenized names.
* Add view master_entities to extract all the master entities.
* Add materialized view search_mv holding all the search relevant information
	about master entities.
* Add materialized view search_words_mv for all unique tokens (used to suggest
	the next best query).
* Index fts_search_idx on materialized view search_mv column tokens to for quick
	FTS.
* Add view untokenized_names holding all master entities with empty tokens,
	signifying unsupported names by to_tsvector.
* Index untokenized_names_idx on materialized view search_mv column names to aid
	quick view untokenized_names query.
* Unique indexes on search_mv and search_words_mv to aid REFRESH CONCURRENTLY
	command.
    * Add function token_creator to tokenized name and enter it as token field in
            alias table
    * Add function refresh_mv which refreshes all materialized views linked with
            FTS - search_mv and search_words_mv
    * Add triggers for insert/update on each entity_header to call the refresh_mv
            function each time a new entity is inserted or updated (master revision).
    * Add trigger for insert on alias to call function token_creator.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant